<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
    <title><{config_item('manager_title')}></title>
    <link href="/public/H-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="/public/H-ui/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="/public/H-ui/hui-iconfont/iconfont.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="pd-20">
	<form action="<{site_url('/manager/tool/adv/save')}>" method="post" class="form form-horizontal" id="add">
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>名称：</label>
			<div class="formControls col-6">
				<input type="text" class="input-text" value="" name="title" datatype="*" nullmsg="请输入名称！">
			</div>
		</div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>类型：</label>
            <div class="formControls col-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" id="type-1" name="type" value="1" checked>
                    <label for="type-1">图片</label>
                </div>
                <div class="radio-box">
                    <input type="radio" id="type-2" name="type" value="2">
                    <label for="type-2">文字</label>
                </div>
                <div class="radio-box">
                    <input type="radio" id="type-3" name="type" value="3">
                    <label for="type-3">代码</label>
                </div>
            </div>
        </div>
        <div class="row cl desc_content" id="desc_content1" style="display: none;">
            <label class="form-label col-3"><span class="c-red">*</span>图片：</label>
            <div class="formControls col-6">
                <{if $item.type==1}>
                <a href="<{$item.desc}>" target="_blank"><img src="<{$item.desc}>" width="50" <{if $item.desc==''}>style="display: none;"<{/if}>></a>
                <{else}>
                <a href="" target="_blank"><img src="" width="50" style="display: none;"></a>
                <{/if}>
                <input type="hidden" value="<{if $item.type==1}><{$item.desc}><{/if}>" name="desc_1">
                <input type="file" name="desc_1_pic" id="desc_1_pic" onchange="upload_file(this);" style="width: 150px;">
            </div>
        </div>
        <div class="row cl desc_content" id="desc_content2" style="display: none;">
            <label class="form-label col-3"><span class="c-red">*</span>文字：</label>
            <div class="formControls col-6">
                <input type="text" class="input-text" value="<{if $item.type==2}><{$item.desc}><{/if}>" name="desc_2">
            </div>
        </div>
        <div class="row cl desc_content" id="desc_content3" style="display: none;">
            <label class="form-label col-3"><span class="c-red">*</span>代码：</label>
            <div class="formControls col-8">
                <textarea name="desc_3" cols="" rows="" class="textarea"  placeholder="代码"><{if $item.type==3}><{$item.desc}><{/if}></textarea>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>链接地址：</label>
            <div class="formControls col-6">
                <input type="text" class="input-text" value="" name="link" datatype="empty|url" nullmsg="请输入名称！">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>广告位：</label>
            <div class="formControls col-6"> <span class="select-box">
				<select name="position_id" class="select">
                    <{foreach $position_list as $key}>
                    <option value="<{$key.id}>"><{$key.name}></option>
                    <{/foreach}>
                </select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>排序：</label>
            <div class="formControls col-6">
                <input type="text" class="input-text" value="99" name="sortnum" datatype="n" nullmsg="排序不能为空！" errormsg="排序只能是数字">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>开始结束时间：</label>
            <div class="formControls col-7">
                <input type="text" class="input-text" value="" name="start_time" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" readonly datatype="*" nullmsg="请选择开始日期！" style="width: 150px">-
                <input type="text" class="input-text" value="" name="end_time" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" readonly datatype="*" nullmsg="请选择结束日期！" style="width: 150px">
            </div>
        </div>
		<div class="row cl">
			<div class="col-10 col-offset-2">
                <input type="hidden" name="id" value="">
				<button onClick="$('#add').submit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
				<button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</div>
</div>
<script type="text/javascript" src="/public/js/jquery.js"></script>
<script type="text/javascript" src="/public/js/validform.js"></script>
<script type="text/javascript" src="/public/js/layer/layer.js"></script>
<script type="text/javascript" src="/public/js/form.js"></script>
<script type="text/javascript" src="/public/js/laydate/laydate.js"></script>
<script type="text/javascript" src="/public/H-ui/js/H-ui.js"></script>
<script type="text/javascript" src="/public/H-ui/js/H-ui.admin.js"></script>
<{ajax_upload()}>
<script type="text/javascript">
    $(function(){
        //验证表单
        $.Tipmsg.r=null;
        $("#add").Validform({
            tiptype:function(msg){
                layer.msg(msg);
            },
            tipSweep:true,
            ajaxPost:true,
            callback:function(data){
                if(data.status=="y"){
                    layer_close();
                }
            }
        });

        //选择类型
        $('[name="type"]').click(function(){
            type_select($(this).val());
        })

        <{if $item.type==''}>
        type_select(1);
        <{else}>
            type_select(<{$item.type}>);
        <{/if}>

        //表单回填
        var formObj = new Form();
        formObj.init(<{ch_json_encode($item)}>);
    })

    //选择位置显示不同类型
    function type_select(type){
        $('.desc_content').hide();
        $('#desc_content'+type).show();
    }

    //添加图片展示
    function show_upload(spec_pic, url){
        $("#"+spec_pic).parent().find('img').attr('src',url);
        $("#"+spec_pic).parent().find('img').show();
        $("#"+spec_pic).parent().find('a').attr('href',url);
        $("#"+spec_pic).parent().find('[type="hidden"]').val(url);
    }
</script>
</body>
</html>